What is codsen-utils?
The codsen-utils package is a collection of utility functions that provide various string manipulation and data processing capabilities. It is designed to help developers perform common tasks more efficiently.
What are codsen-utils's main functionalities?
String Manipulation
The rApply function allows you to apply a series of string replacements based on specified ranges. This is useful for batch processing of string modifications.
const { rApply } = require('codsen-utils');
const str = 'Hello, world!';
const ranges = [[7, 12, 'universe']];
const result = rApply(str, ranges);
console.log(result); // 'Hello, universe!'
Data Validation
The isStr function checks if a given input is a string. This is a simple utility for type validation in JavaScript.
const { isStr } = require('codsen-utils');
console.log(isStr('Hello')); // true
console.log(isStr(123)); // false
Other packages similar to codsen-utils
lodash
Lodash is a popular utility library that provides a wide range of functions for manipulating arrays, objects, and other data types. It offers more comprehensive functionality compared to codsen-utils, which is more focused on string manipulation and specific utilities.
underscore
Underscore is another utility library similar to Lodash, providing functional programming helpers without extending any built-in objects. It is comparable to codsen-utils in terms of providing utility functions, but it covers a broader range of data manipulation tasks.
validator
Validator is a library for string validation and sanitization. While codsen-utils offers some basic validation functions, validator is more specialized and comprehensive in terms of validating and sanitizing strings.
codsen-utils
Various utility functions
Install
This package is pure ESM.
npm i codsen-utils
Quick Take
import { strict as assert } from "assert";
import { isNumberChar } from "codsen-utils";
assert.equal(isNumberChar("z"), false);
assert.equal(isNumberChar("0"), true);
Documentation
Please visit codsen.com for a full description of the API.
Contributing
To report bugs or request features or assistance, raise an issue on GitHub.
Licence
MIT License.
Copyright © 2010-2024 Roy Revelt and other contributors.